/**
 * 
 */
package com.nl.controller.web.controller;

import java.io.IOException;
import java.io.InputStream;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.nl.controller.web.service.Sms5gService;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 沈
 *
 */
@RestController
@Slf4j
@RequestMapping("sms5gInterface")
public class Sms5gController {
	
	@Autowired
	private Sms5gService sms5gService;
	
	//5G平台模板审核结果通知
	@RequestMapping("templateCheckResult")
	private JSONObject templateCheckResult(
//			@RequestParam(value = "templateCheckResult", required = true) String templateCheckResult,
			HttpServletRequest request) {
		InputStream in;
		 String reqJson="";
		try {
			in = request.getInputStream();
			reqJson = IOUtils.toString(in, "utf-8");
			log.info("【5G平台模板审核结果通知】请求参数:"+reqJson);
		} catch (IOException e) {
			e.printStackTrace();
			log.error(e.toString());
		}
		JSONObject map = new JSONObject();
		if (null== reqJson) {
			map.put("resp", "请输入请求参数");
			return map;
		}
		
		map = sms5gService.templateCheckResult(/*templateCheckResult*/reqJson);
		log.info("【5G平台模板审核结果通知】返回数据：{}", map);
		return map;
	}
	
	@RequestMapping("smsSendResult")
	private JSONObject smsSendResult(
//			@RequestParam(value = "smsSendResult", required = true) String smsSendResult,
			HttpServletRequest request) {
		InputStream in;
		 String reqJson="";
		try {
			in = request.getInputStream();
			reqJson = IOUtils.toString(in, "utf-8");
			log.info("【5G平台信息发送结果通知】请求参数:"+reqJson);
		} catch (IOException e) {
			e.printStackTrace();
			log.error(e.toString());
		}
		JSONObject map = new JSONObject();
		if (null== reqJson) {
			map.put("resp", "请输入请求参数");
			return map;
		}
		
		map = sms5gService.smsSendResult(/*smsSendResult*/reqJson);
		log.info("【5G平台信息发送结果通知】返回数据：{}", map);
		return map;
	}
	
	
	
}
